﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;

namespace Ruleweaver.Conditions
{
	public sealed class CompositeConditionSource : IConditionSource
	{
		public CompositeConditionSource(IEnumerable<IConditionSource> sources)
		{
			Contract.Requires(sources != null);

			Sources = sources.ToList().AsReadOnly();
		}

		public CompositeConditionSource(params IConditionSource[] sources) : this(sources as IEnumerable<IConditionSource>)
		{}

		#region IConditionSource

		public IEnumerable<Condition> GetConditions()
		{
			return Sources.SelectMany(source => source.GetConditions());
		}
		#endregion

		public ReadOnlyCollection<IConditionSource> Sources { get; private set; }
	}
}